package com.itheima.service.impl;

import com.itheima.dao.UserDao;
import com.itheima.dao.impl.UserDaoImpl;
import com.itheima.service.UserService;

public class UserServiceImpl implements UserService {

    //在创建UserServiceImpl对象的同时告诉spring从容器中获取UserDao对象赋值给userDao变量
    private UserDao userDao;
    private String name;
    private Integer age;

    public void setUserDao(UserDao userDao) {
        //这是一个使User中的save方法可以实现的构造方法
        this.userDao = userDao;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setAge(Integer age) {
        this.age = age;
    }
    public UserServiceImpl(){
        System.out.println("UserServiceImpl空餐构造");
    }
    public UserServiceImpl(UserDao userDao, String name) {
        this.userDao = userDao;
        this.name = name;
        System.out.println("UserServiceImpl两个参数构造");
    }

    public UserServiceImpl(UserDao userDao, Integer age, String name) {
        this.userDao = userDao;
        this.name = name;
        this.age = age;
        System.out.println("UserServiceImpl三个参数构造");
    }


    public void save() {
        System.out.println("UserServiceImpl save is running..."+name+","+age);

        //调用dao层对应的方法
        userDao.save();
    }
}